class Bullet {
    constructor(ctx, hero) {
        this.ctx = ctx;
        this.img = new Image();
        this.img.src = 'images/bullet.png'
        let w = 62 / 2;
        let h = 108 / 2;
        this.init = {
            x: hero.init.x + hero.init.w / 2 - w / 2,
            y: hero.init.y - h / 2,
            w: w,
            h: h
        }
        this.speed = 3;
        this.status = true;
    }

    draw() {
        this.init.y -= this.speed;
        //显示
        if (this.status) {
            this.ctx.drawImage(this.img, this.init.x, this.init.y, this.init.w, this.init.h);
        }
        //更新顾虑不需要的
        if (this.init.y < 0) {
            this.status = false;
        }
    }
}

export default Bullet;